package com.bookcloud.java21.chapter5.对象引用参数52;

public class ObjectReferenceParameters {

  public static void modifyPerson(Person person) {
    person.setName("张三");
    person.setAge(18);
  }

  // 创建一个person对象
  public static Person createPerson() {
    Person person = new Person("古三通", 90);
    return person;
  }

  public static void main(String[] args) {
    Person person = new Person("李四", 20);
    System.out.println("修改前：" + person.getName() + "，" + person.getAge());
    System.out.println("修改前：" + person);
    // 传递对象的地址（对象引用）
    modifyPerson(person);
    System.out.println("修改后：" + person.getName() + "，" + person.getAge());
    // 演示方法创建对象， 并返回对象引用
    Person person2 = createPerson();
    System.out.println("静态方法创建的person对象：" + person2);
    System.out.println("静态方法创建的person对象：" + person2);
    person2.setAge(100);
    person2.setName("张华");
    System.out.println("修改后的静态方法创建的person对象：" + person2);
  }
}
